package org.mics.hikariMonitor.controller;

import java.util.Date;
import java.util.List;

import javax.annotation.Resource;

import org.mics.core.response.MultipleDataResponse;
import org.mics.hikariMonitor.service.HikariMonitorDataService;
import org.mics.hikariMonitor.vo.MonitorDataVO;
import org.mics.token.annotation.IgnoreToken;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;

/**
 * hikariMonitor
 * @author mics
 * @date 2022-7-21
 * @version  1.0
 */
@Tag(name="hikari监听器")
@RestController
@RequestMapping("/hikariMonitor")
public class HikariMonitorController {
	@Resource
	private HikariMonitorDataService hikariMonitorDataService ;
	
	@RequestMapping(value = "/listByHour",method = RequestMethod.GET)
	@Operation(description = "查询最近24小时各小时情况")
	@IgnoreToken
	public MultipleDataResponse<MonitorDataVO> listByHour() {
		List<MonitorDataVO> monitorDataVOs =  hikariMonitorDataService.listByHour();
		return new MultipleDataResponse<MonitorDataVO>(monitorDataVOs);
	}
	
	@RequestMapping(value = "/listByMinite/{date}",method = RequestMethod.GET)
	@Operation(description = "查询指定日期指定小时每分钟情况")
	@IgnoreToken
	public MultipleDataResponse<MonitorDataVO> listByMinite(@Parameter(description = "指定时间")@PathVariable("date")Date date) {
		List<MonitorDataVO> monitorDataVOs =  hikariMonitorDataService.listByMinite(date);
		return new MultipleDataResponse<MonitorDataVO>(monitorDataVOs);
	}
	
}
